package Control;

import java.util.ArrayList;

import javax.swing.JOptionPane;

import Chat.mysqlConnection;
import Entity.MsgPackage;
import GUI.ScreenManager;
import GUI.requestFreeze_GUI;

public class requestFreeze_control {
	
	
private requestFreeze_GUI freezeReq_GUI;
private MsgPackage freezeReq_msg;
private ArrayList<Integer> result;


public requestFreeze_control(){
	freezeReq_GUI = new requestFreeze_GUI();
	freezeReq_msg = new MsgPackage(); 
}

public ArrayList<Integer> getActive(){
	freezeReq_msg.setOp_code(OP_CODE.GET_ACTIVE);
	freezeReq_msg.setObject(null);
	ScreenManager.getConnection().accept(freezeReq_msg);
	
	//while(ScreenManager.getConnection().getAnswerReceivedFlag() == false);	//wait until flag is changed and shows that result was received from server
	Object o = ScreenManager.getConnection().cclient.getMessage();

	//Object o = ScreenManager.getConnection().getResultobject();
	 result = (ArrayList<Integer>)o;
	return result;
	
	
}
public void freeze_req(Integer req_num){
	
	freezeReq_msg.setOp_code(OP_CODE.FREEZE_REQ);
	freezeReq_msg.setObject(req_num);
	ScreenManager.getConnection().accept(freezeReq_msg);
	
	Object o = ScreenManager.getConnection().cclient.getMessage();
    Boolean flag=(Boolean) o;
    if(!flag){
			JOptionPane.showMessageDialog(null, "The system was unable to freeze the request", "Error", JOptionPane.ERROR_MESSAGE);		
    }
    else{
			JOptionPane.showMessageDialog(null, "The request was freezed successfully", "", JOptionPane.INFORMATION_MESSAGE);		
    }
	

	
}

public requestFreeze_GUI getFreezeReq_GUI() {
	return freezeReq_GUI;
}

public void setFreezeReq_GUI(requestFreeze_GUI freezeReq_GUI) {
	this.freezeReq_GUI = freezeReq_GUI;
}

public MsgPackage getFreezeReq_msg() {
	return freezeReq_msg;
}

public void setFreezeReq_msg(MsgPackage freezeReq_msg) {
	this.freezeReq_msg = freezeReq_msg;
}





}
